
FROM golang:latest AS builder

WORKDIR /app

COPY . .
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod download

# 构建可执行文件
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o ./appcmd

FROM alpine:latest


WORKDIR /app
COPY --from=builder /app/appcmd ./

# 确保可执行文件有执行权限
RUN chmod +x ./appcmd

CMD ["./appcmd"]

